const Base = require('../base.js');
const area = require('../../common/area.js');
/*获取省市区*/
module.exports = class extends Base {
    async indexAction() {
        const ar = new area()
       
        let province = ar.province_list,
            chengsi = []
        if (this.get("type")) {
            let quyu = 10000
            if (this.get("type") == 1) {
                province = ar.city_list
            }
            if (this.get("type") == 2) {
                quyu = 100
                province = ar.county_list
            }
            for (var key in province) {
                let sd_der = {}
                if ((key - this.get("code")) < quyu && (key - this.get("code")) > 0) {
                    sd_der.name = province[key]
                    sd_der.code = key
                    chengsi.push(sd_der)
                }
            }

        } else {
            for (var key in province) {
                let sd_der = {}
                sd_der.name = province[key]
                sd_der.code = key
                chengsi.push(sd_der)
            }
        }
        return this.success(chengsi); //2输出json 推荐
    }
};
